import React, {Component, useEffect, useState} from 'react';
import {Image, View} from '@tarojs/components';
import Taro from '@tarojs/taro';

import NavBar from '../fit';
import './port.scss';

const Port = () => {
  //保存个人发帖的数据
  const [selfData,setData]=useState([{"picture":0}])

  useEffect(()=>{
    Taro.cloud.callFunction({
      name:"comments",
      data:{
        $url:"find_one",
      }
    }).then(res=>{
      console.log("res:",res.result.res.data)
      setData(res.result.res.data)
    })
  },[])
  console.log("data:",selfData!==[] ?(selfData[1]):[])

  const toBack=()=>{
    Taro.navigateBack().then();
  }

  const[port]=useState(
    [
      {
        title:"标题",
        content:"lalallalall",
        imgSrc:"",
      }
  ]
  );
  const portport = selfData.map(content => (
    <View className="port">
      <View className="title">{content.title}</View>
      <View className="content">{content.contents}</View>
      <Image className="img" src={content.picture===null? null:content.picture[0]} />
    </View>
  ))

  return (
    <View className="box">
      <View className="aa">
        <NavBar
          title=" "
          back={true}
        />
        <View className="box2">发表</View>

      </View>

      <View className="box3">
        {portport}
      </View>

    </View>
  )
}
export default Port;
